<% layout('/layouts/default.html', {title: '药材检验信息管理', libs: ['validate']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(ownMedicineInspectionInformation.isNewRecord ? '新增药材检验信息' : '编辑药材检验信息')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${ownMedicineInspectionInformation}" action="${ctx}/own/ownMedicineInspectionInformation/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<div class="row" id="info" hidden>
					<div class="col-xs-3">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">${text('品名')}：</label>
							<label class="col-sm-8" id="receiptnm"></label>
						</div>
					</div>
					<div class="col-xs-3">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">${text('待检重量(g)')}：</label>
							<label class="col-sm-8" id="receiptw"></label>
						</div>
					</div>
					<div class="col-xs-3">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">${text('药材批次码')}：</label>
							<label class="col-sm-8" id="receiptpc"></label>
						</div>
					</div>
					<div class="col-xs-3">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">${text('收获时间')}：</label>
							<label class="col-sm-8" id="receipttt"></label>
						</div>
					</div>
				</div>
				<#form:hidden path="id"/>
				<#form:hidden id="ownMedicineReceiptInformationId" path="ownMedicineReceiptInformationId"/>
				<#form:hidden id="bmBatchCode" path="bmBatchCode"/>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('药材批次号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:listselect id="medicineBatchId" title="药材批次号" labelPath="medicineBatchId"
								url="${ctx}/own/ownMedicineReceiptInformation/findByKey" allowClear="false" checkbox="false"
								itemCode="medicineBatchId" itemName="medicineBatchId" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('药材剩余重量(g)')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="residualWeight" class="form-control number required"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('检验方法')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="checkMethod" dictType="own_medicine_check_method" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('质量级别')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:radio path="checkGrade" dictType="own_medicine_check_grade" class="form-control required" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('粗加工方法')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:checkbox path="checkThickMethod" dictType="own_medicine_thick_method" class="form-control" /><br/>
								<div class="form-group"  style="margin-left: -40%">
									<label class="control-label col-sm-4" title="">
										<span class="required hide">*</span> ${text('其它')}：<i class="fa icon-question hide"></i>
									</label>
									<div class="col-sm-4">
										<#form:input id="other" path="checkThickMethod" class="form-control" />
									</div>
									<label class="control-label col-sm-4" title="" style="margin-left: -15%;">
										${text('（多种方法用","隔开）')}
									</label>
								</div>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('贮藏条件')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="checkCondition" maxlength="50" class="form-control required"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('检验人员')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="checkUser" maxlength="50" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('检验时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="checkTime" readonly="true" maxlength="20" class="form-control Wdate required"
									dataFormat="datetime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:true});"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('报告类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="reportType" dictType="own_medicine_report_type" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('报告地址')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="reportAddress" maxlength="20" class="form-control required"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="255" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('own:ownMedicineInspectionInformation:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
//选择药材批次号回调方法
function  listselectCallback(id, act, index, layero, selectData) {
	if (id == 'medicineBatchId' && (act == 'ok' || act == 'clear')){
		for (let key in selectData){
			$('#ownMedicineReceiptInformationId').val(selectData[key]['id']);
			$('#bmBatchCode').val(selectData[key]['bmBatchCode']);
			$('#residualWeight').val(selectData[key]['weight']);
			$("#receiptnm").text(selectData[key].varietyName);
			$("#receiptw").text(selectData[key].weight);
			$("#receiptpc").text(selectData[key].bmBatchCode);
			$("#receipttt").text(selectData[key].harvestTime);
			$("#info").show();
			break;
		}
	}
}
$(function(){
	$("#residualWeight").attr("readonly","readonly");
	var jsss = "${ownMedicineInspectionInformation.isNewRecord}"; //获取beetl的值
	if (jsss == 'false'){
		$("#medicineBatchIdName").attr("disabled","disabled");
		$("#info").show();
	}

	var allMethod = "${ownMedicineInspectionInformation.checkThickMethod}";
	var dictMethod = js.getDictLabel(${@DictUtils.getDictListJson('own_medicine_thick_method')}, allMethod, '未知', true);
	var remainingMethod = allMethod.substr(dictMethod.length+1);
	$("#other").val(remainingMethod);

	$.ajax({
		url: "${ctx}/own/ownMedicineReceiptInformation/findByModelId",
		type: "get",
		data: {"id": "${ownMedicineInspectionInformation.ownMedicineReceiptInformationId}"},
		dataType: "json",
		success: function (data) {
			if (data.ownMedicineReceiptInformation){
				$("#receiptnm").text(data.ownMedicineReceiptInformation.varietyName);
				$("#receiptw").text(data.ownMedicineReceiptInformation.weight);
				$("#receiptpc").text(data.ownMedicineReceiptInformation.bmBatchCode);
				$("#receipttt").text(data.ownMedicineReceiptInformation.harvestTime);
			}else {
				js.showErrorMessage("获取错误！", data.msg);
			}
		},
		error: function (e) {
			js.showErrorMessage("错误", e);
		}
	});
});
</script>